<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的关注</title>
     <link href="Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="Scripts/bootstrap/css/font-awesome.css" rel="stylesheet">
 	<link href="Style/skin/css/style.css" rel="stylesheet" type="text/css" />
	<link href="Style/skin/css/animate.css" rel="stylesheet" type="text/css" />
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
						<div class="ibox-content">
							<table  class="table  table-striped">
								<thead>
									<tr>
									<th># </th>
									<th>流程 </th>
									<th>标题 </th>
									<th>发起人</th>
									<th>发起日期</th>
									<th>状态</th>
									<th>停留节点 </th>
									<th>当前处理人 </th>
									<th>操作</th>
									</tr>
								</thead>
								<tbody id="Table1"></tbody>
							</table>
							
						</div>
				
				</div>
				
	
<script language="JavaScript" src="./Comm/JScript.js" type="text/javascript" ></script>
    <script type="text/javascript" src="./Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="./Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="./Scripts/QueryString.js" type="text/javascript"></script>
    <script src="./Scripts/config.js" type="text/javascript"></script>    
    <script src="./Comm/Gener.js" type="text/javascript"></script>    
    <script language="javascript" type="text/javascript" >
       
        //页面启动函数.
        $(function () {

            var handler = new HttpHandler("BP.WF.HttpHandler.WF");
            var data = handler.DoMethodReturnString("Focus_Init");

            if (data.indexOf('err@') == 0) {
                alert(data);
            }

            data = JSON.parse(data);

            var webUser = new WebUser();

            var listbox = "";
            //增加处理.
            for (var i = 0; i < data.length; i++) {

                var en = data[i];

                //是否可以执行当前工作?
                var isCanDo = false;
                if (en.TodoEmps != null) {
                    if (en.TodoEmps.indexOf(webUser.No) != -1)
                        isCanDo = true;
                }

                //获得icon.
                var icon = GenerICON(isCanDo, en.WFState);

                // 获得颜色.
                var color = GenerColor(en.WFState, isCanDo);



                listbox += "<tr ><td class=Idx>" + i + "</td>";
                listbox += "<td>" + en.FlowName + "</td>";
                //  listbox += "<td>" + en.Title + "</td>";
                listbox += "<td><a href=\"javascript:OpenIt('" + en.WFState + "','" + en.WorkID + "','" + en.FK_Flow + "','" + en.FK_Node + "','" + en.TodoEmps + "','" + webUser.No + "')\">" + en.Title + "</td>";

                listbox += "<td>" + en.StarterName + "</td>";
                listbox += "<td>" + en.RDT + "</td>";

                listbox += "<td><font color='" + color + "'>" + GetWFState(en.WFState, isCanDo) + "</font></td>";


                listbox += "<td>" + en.NodeName + "</td>";
                listbox += "<td>" + en.TodoEmps + "</td>";

                listbox += "<td>";
                listbox += "<a href=\"javascript:Delete('" + en.WorkID + "')\">删除</a>";
                listbox += "</td>";
                listbox += "</tr>";
            }

            $('#Table1').html(listbox);

        });

        function GenerColor(wfState, isCanDo) {

            if (isCanDo == true && wfState != 3)
                return "red";

            if (wfState == 5) {
                return "yellow";
            }

            if (wfState == 3) {
                return "green";
            }

            if (wfState == 2)
                return "";

            return "";
        }

        function GenerICON(isCanDo, wfState) {

            if (wfState == 3)
                icon = "./Img/WFState/Complete.png";  //已经完成.
            else if (wfState == 2)
                icon = "./Img/WFState/Runing.png"; //运行中. 
            else if (wfState == 5)
                icon = "./Img/WFState/ReturnSta.png"; //退回.
            else
                icon = "./Img/WFState/Etc.png"; //其他.

            if (isCanDo == true && wfState != 3)
                icon = "./Img/WFState/Todo.png"; //其他.

            return icon;
        }

        function OpenIt(wfState, workid, flowNo, nodeID, emps, userNo) {

            var url = "";
            if (wfState != 3 && emps.indexOf(userNo) >= 0) {
                url = "MyFlow.htm?WorkID=" + workid + "&FK_Flow=" + flowNo + "&FK_Node=" + nodeID;
            } else {
                url = "WFRpt.htm?WorkID=" + workid + "&FK_Flow=" + flowNo;
            }
            WinOpen(url);
            return;

            layer.open({
                skin: 'layer-class',
                type: 2,
                title: '我的流程',
                area: ['96%', '90%'],
                content: url
            });
        }

        function GetWFState(wfState, isCanDo) {

            if (isCanDo == true && wfState != 3)
                return "待办";

            if (wfState == 5) {
                return "退回";
            }

            if (wfState == 3) {
                return "已完成";
            }

            if (wfState == 2)
                return "运行中";

            return "其他";
        }

        function Delete(no) {

            if (window.confirm('您确定要删除吗？') == false)
                return;

            var handler = new HttpHandler("BP.WF.HttpHandler.WF");
            handler.AddPara("WorkID", no);
            var data = handler.DoMethodReturnString("Focus_Delete");

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }
            window.location.href = window.location.href;
        }

     </script>
</body>
</html>
